package com.joysw.ui.fragment;

import butterknife.ButterKnife;
import butterknife.InjectView;

import com.google.gson.Gson;
import com.joysw.R;
import com.joysw.models.DtqModelMsg;
import com.joysw.ui.adapter.DtqListAdapter;
import com.joysw.ui.adapter.FxljListAdapter;
import com.joysw.view.TitleBarView;

import android.content.Context;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;

/**   
 * @Title: DtqFrgment.java 
 * @Package com.joysw.ui.fragment 
 * @Description: 分享的链接
 * @author LIMINGYAN  
 * @date 2015年3月28日 下午9:27:29 
 * @version V1.0   
 */
public class FxjlTabTwoFrgment extends BaseFragment{
	private static final String TAG = "FxjlTabTwoFrgment";
	private Context mContext;
	private View mBaseView;
	
	@InjectView(R.id.fxjl_tab_two_list)
	ListView mListView;
	
	private FxljListAdapter mAdapter;

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		mContext = getActivity();
		mBaseView = inflater.inflate(R.layout.fragment_fxjl_tab_two, container,
				false);
		ButterKnife.inject(this, mBaseView);
		initView();
		
		new MyTask().execute();
		return mBaseView;
	}
	
	private void initView(){
		
	}
	
	class MyTask extends AsyncTask<Void, Void, DtqModelMsg> {

		@Override
		protected DtqModelMsg doInBackground(Void... params) {
			String json = "{\"code\":200,\"msg\":\"ok\",list:["
					+ "{\"id\":111,\"avator\":\"http://img0.bdstatic.com/img/image/shouye/leimu/mingxing2.jpg\",\"name\":\"柠檬食品分销官\",\"content\":\"亲们，柠檬大龙到货，价格便宜，质量好。欢迎大家前来团购\",\"urls\":[]},"
					+ "{\"id\":113,\"avator\":\"http://img0.bdstatic.com/img/image/shouye/leimu/mingxing6.jpg\",\"name\":\"美丽衣冠\",\"content\":\"一款翻领的衬衫，文艺小清新。多种颜色，喜欢就来吧！\",\"urls\":[]}]}";
			Gson gson = new Gson();
			DtqModelMsg msg = gson.fromJson(json, DtqModelMsg.class);
			return msg;
		}

		@Override
		protected void onPostExecute(DtqModelMsg result) {
			mAdapter = new FxljListAdapter(getActivity(), result.list);
			mListView.setAdapter(mAdapter);
		}

	}
}
